import request from '@/utils/request'
import { APPID, APPSECRET, env } from '@/api/config/appconfig'
const goodsApi = {

  // 触发云函数
  invokeCloudFunction(access_token, data) {
    return request({
      url: `/tcb/invokecloudfunction?access_token=${access_token}&env=${env}&name=httpApi`,
      method: 'post',
      baseURL: '/api',
      data
    })
  },

  // 获取access_token
  getAccess_token() {
    return request({
      url: `/cgi-bin/token?grant_type=client_credential&appid=${APPID}&secret=${APPSECRET}`,
      method: 'get',
      baseURL: '/api'
    })
  },
  // 获取商品类型列表
  get(access_token, data) {
    return request({
      url: `/tcb/databasequery?access_token=${access_token}`,
      method: 'post',
      baseURL: '/api',
      data
    })
  },
  // 添加商品类型
  add(access_token, data) {
    return request({
      url: `/tcb/databaseadd?access_token=${access_token}`,
      method: 'post',
      baseURL: 'api',
      data
    })
  },
  // 修改商品类型
  update(access_token, data) {
    return request({
      url: `/tcb/databaseupdate?access_token=${access_token}`,
      method: 'post',
      baseURL: 'api',
      data
    })
  },
  // 删除商品类型
  delete(access_token, data) {
    return request({
      url: `/tcb/databasedelete?access_token=${access_token}`,
      method: 'post',
      baseURL: 'api',
      data
    })
  },
  // 获取记录数量
  getRecordCount(access_token, data) {
    return request({
      url: `/tcb/databasecount?access_token=${access_token}`,
      method: 'post',
      baseURL: 'api',
      data
    })
  }
}

export default goodsApi
